package it.asvp.asvp_portal.data.entity.member;


import static javax.persistence.GenerationType.IDENTITY;
import it.asvp.asvp_portal.asvp_util.enumerative.Role;
import it.asvp.asvp_portal.data.entity.domain.BaseEntity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

@SuppressWarnings("serial")
@Entity
@Table(name = "member_account", catalog = "asvp_db", uniqueConstraints = {
		@UniqueConstraint(columnNames = "id_member"),
		@UniqueConstraint(columnNames = "login") })
public class MemberAccount extends BaseEntity {


	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_member", unique = true, nullable = false)
	private Member member;
	
	@Column(name = "login", unique = true, nullable = false, length = 50)
	private String login;
	
	@Column(name = "password", nullable = false, length = 50)
	private String password;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "expire_date", nullable = false, length = 10)
	private Date expireDate;

	@Enumerated(EnumType.STRING)
	private Role role;
	
	@Column(name = "enabled", nullable = false)
	private boolean enabled;
		
	public MemberAccount() {
	}

	public MemberAccount(Member member, String login, String password,
			Date lastUpdate, Date expireDate, Date createdOn) {
		this.member = member;
		this.login = login;
		this.password = password;
		this.lastUpdate = lastUpdate;
		this.expireDate = expireDate;
		this.createdOn = createdOn;
	}

	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	public Member getMember() {
		return this.member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}
	
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Date getExpireDate() {
		return expireDate;
	}
	
	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}
	
	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	
	
}
